﻿using SqlKata;

namespace Zws.Dapper.Interfaces
{
    public interface IDapperRepository
    {
        /// <summary>
        /// 批量查,查单个标量值，如总数
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        Task<int> CountAsync(string sql, object? param = null);


        /// <summary>
        /// 查询单条
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sql"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        Task<T?> QuerySingleAsync<T>(string sql, object? param = null) where T : class;
        /// <summary>
        /// 查询多条
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sql"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        Task<List<T>> QueryAsync<T>(string sql, object? param = null) where T : class;

        /// <summary>
        /// 获取实体查询对象
        /// </summary>
        Query GenerateSqlQuery();

        string QueryToSql(Query query);
        Task ExecuteAsync(string sql, object? param = null);
    }
}
